#!/usr/bin/env python
# coding: utf-8

# # 1.request测试和学习

# In[3]:


import requests


# In[7]:


response = requests.get("https://cn.bing.com/search?q=api")

response
# # 1.二进制响应内容
# 
# * bytes
# * content（content作为响应内容的数据样态：二进制） 可以识别任何格式的网页教程，但是不利于分析（流媒体:如 图片，视频，音频）
# * json()数据交换的常用表达式

# In[ ]:





# In[8]:


response.content


# ## 2.Jason响应内容

# In[14]:


r = requests.get('https://api.github.com/events')


# In[15]:


r.json()[0]


# # 3.payload
# * 作为请求输入的数据

# In[19]:


payload = {"name":"simin","password":123456}
r = requests.get("http://httpbin.org/get",params = payload)


# In[20]:


r


# In[21]:


r.content


# In[22]:


r.json


# # 2.实践face++

# In[18]:


# 1. 导入需要的request 模板
import requests

# 2.准备api的接口身份

API_Key="UmmHosUEZzJI61aqoyKPhSB8sm93xnLc"
API_Secret="3ZTKuLwcvpALsHyFu4Z-UIL5NSIR9af_"

# 3 准备baseURI（face detect)
base_url = "https://api-cn.faceplusplus.com/facepp/v3/detect"

# 4. 请求方法：POST

# 5.准备请求参数： payload

payload = {
    "api_key":API_Key,
    "api_secret":API_Secret,
    "image_url":"https://tse1-mm.cn.bing.net/th/id/R-C.cb42580f903c191fa5c28d854e46cb40?rik=SQTRXnycXBeDcw&riu=http%3a%2f%2fwww.46ps.com%2fuploadfile%2f2012%2f0724%2f20120724124340448.jpg&ehk=Pl4rjfD6lSzxoYC8j2SrHHwYqhoNj9LG%2fDg4usibDx0%3d&risl=&pid=ImgRaw&r=0g",
    #"return_landmark":1,
    "return_attributes":'gender,age,smiling'
    
}

# 6.请求数据

r = requests.post(base_url,payload)


# In[19]:


r


# In[20]:


r.content


# In[ ]:




